package eleven;

import java.util.Arrays;

/**
 * 2656. K 个元素的最大和
 */
public class Day15 {
    public int maximizeSum(int[] nums, int k) {
        int n = nums.length,sum = 0,maxValue = 0;
        for (int i = 0; i < n; i++) if (nums[i] > maxValue) maxValue = nums[i];
        sum = maxValue;
        for (int i = 1; i < k; i++) {
            maxValue += 1;
            sum += maxValue;
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5};
        Day15 day15 = new Day15();
        System.out.println(day15.maximizeSum(nums,3));

    }
}
